<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>单选框</title>
<script>
  function sbt() {
    var arr = document.getElementsByName("sex");
    for (var i = 0; i < arr.length; i++) {
      if (arr[i].checked) {
        alert("你选择的是：" + arr[i].value);
        return;
      }
    }
  }
</script>
</head>
<body>
  <label>
    <input type="radio" name="sex" value="male">
    男
  </label>
  <br>
  <label>
    <input type="radio" name="sex" value="female">
    女
  </label>
  <br>
  <input type="button" value="确定" onclick="sbt()">
</body>
</html>